<include file="Public/header"/>
<div class="row">
    <div class="ibox-content">
        <div class="deal-bd order-bottom">订单管理</div>
        <form class="layui-form" action="" method="get" autocomplete="off" id="orderform">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input style="width:200px;" type="text" name="memberid" autocomplete="off" placeholder="请输入商户号"
                           class="layui-input" value="<{$_GET['memberid']}>" lay-key="1">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input style="width:200px;" type="text" name="orderid" autocomplete="off" placeholder="商户订单号"
                           class="layui-input" value="<{$_GET['orderid']}>" lay-key="1">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input style="width:200px;" type="text" name="pay_orderid" autocomplete="off" placeholder="平台订单号"
                           class="layui-input" value="<{$_GET['pay_orderid']}>" lay-key="1">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input style="width:200px;" type="text" class="layui-input " name="createtime" id="createtime"
                           placeholder="提交时间段" value="<{$_GET['createtime']}>">
                </div>
                <div class="layui-input-inline">
                    <input style="width:200px;" type="text" class="layui-input" name="successtime" id="successtime"
                           placeholder="成功时间段" value="<{$_GET['successtime']}>">
                </div>
            </div>
            <br>
            <div class="layui-inline" style="margin-top: 20px;">
                <div class="layui-input-inline" style="width:200px;">
                    <select name="tongdao">
                        <option value="">全部通道</option>
                        <volist name="tongdaolist" id="vo">
                            <option
                            <if condition="$_GET[tongdao] eq $vo[id]">selected</if>
                            value="<{$vo.id}>"><{$vo.title}></option>
                        </volist>
                    </select>
                </div>
                <div class="layui-input-inline" style="width:200px;">
                    <select name="bank">
                        <option value="">全部银行</option>
                        <volist name="banklist" id="vo">
                            <option
                            <if condition="$_GET[bank] eq $vo[id]">selected</if>
                            value="<{$vo.id}>"><{$vo.name}></option>
                        </volist>
                    </select>
                </div>
                <div class="layui-input-inline" style="width:200px;">
                    <select name="status">
                        <option value="">全部状态</option>
                        <option
                        <if condition="$_GET[status] neq '' && $_GET[status] eq 0">selected</if>
                        value="0">未处理</option>
                        <option
                        <if condition="$_GET[status] eq 1">selected</if>
                        value="1">成功，未返回</option>
                        <option
                        <if condition="$_GET[status] eq 2">selected</if>
                        value="2">成功，已返回</option>
                        <option
                        <if condition="$_GET[status] eq '1or2'">selected</if>
                        value="1or2">成功，已/未返回</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width:200px;">
                    <select name="ddlx">
                        <option value="">订单类型</option>
                        <option
                        <if condition="$_GET[ddlx] neq '' && $_GET[ddlx] eq 0">selected</if>
                        value="0">收款订单</option>
                        <option
                        <if condition="$_GET[ddlx] eq 1">selected</if>
                        value="1">充值订单</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline" style="margin-top: 20px;">
                <button type="submit" class="layui-btn layui-bg-blue"><i class="fa fa-search"></i> 搜索</button>
                <a class="layui-btn layui-bg-cyan" onclick="chooseOrder_del()"><i class="fa fa-trash-o"></i> 删除上月订单</a>
            </div>
            <br/>
            <div class="layui-inline" style="margin-top: 20px;">
                    <input type="text" lay-verify="required" id="additional_order" class="layui-input"
                    placeholder="请输入平台订单号">
                    <a class="layui-btn  layui-btn-danger" onclick="additional_order()"><i class="fa fa-trash-o"></i>
                        确认补单</a>
            </div>

        </form>
    </div>
    <div class="container-fluid bg-gray">
        <div class="row">
            <div class="col-xs-6 col-md-4 ">
                <div class="num-box">
                    <div class="left-img"><img src="Public/Front/img/icon-1.png" alt=""></div>
                    <div class="right-num">
                        <p class="num-title">成功交易总金额</p>
                        <p class="main-num"><{$stamountZh}></p>
                    </div>
                </div>
            </div>
            <div class="col-xs-6 col-md-4 ">
                <div class="num-box">
                    <div class="left-img"><img src="Public/Front/img/icon-3.png" alt=""></div>
                    <div class="right-num">
                        <p class="num-title">手续费总金额</p>
                        <p class="main-num"><{$strateZh}></p>
                    </div>
                </div>
            </div>
            <div class="col-xs-6 col-md-4 ">
                <div class="num-box">
                    <div class="left-img"><img src="Public/Front/img/icon-2.png" alt=""></div>
                    <div class="right-num">
                        <p class="num-title">实际总金额</p>
                        <p class="main-num"><{$strealmoneyZh}></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--条件筛选过滤-->
    <div style="margin-left:20px;margin-top: 10px;">
        <button class="btn btn-primary" data-toggle="modal" data-target="#myModal">筛选条件</button>
    </div>
    <div class="tablediv">
        <table class="table table-hover choosetable">
            <thead>
            <tr>
                <th>记录ID</th>
                <th>商户号</th>
                <th>商户订单号</th>
                <th>平台订单号</th>
                <th>交易金额</th>
                <th style="display:none;">手续费</th>
                <th style="display:none;">实际金额</th>
                <th>提交时间</th>
                <th>成功时间</th>
                <th>支付通道</th>
                <th style="display:none;">支付银行</th>
                <th>来源地址</th>
                <th>状态</th>
                <th>操作</th>
                <th>查看</th>
            </tr>
            </thead>
            <tbody>
            <volist name="list" id="vo">
                <tr>
                    <td><{$vo.id}></td>
                    <td><{$vo.pay_memberid}></td>
                    <td><{$vo[out_trade_id]}></td>
                    <td><{$vo[pay_orderid]}></td>
                    <td><{$vo.pay_amount}></td>
                    <td style="display:none;"><{$vo.pay_poundage}></td>
                    <td style="display:none;"><{$vo.pay_actualamount}></td>
                    <td><{$vo.pay_applydate|date='Y-m-d H:i:s',###}></td>
                    <td>
                        <if condition="$vo[pay_successdate]"><{$vo.pay_successdate|date='Y-m-d H:i:s',###}>
                            <else/>
                            ---
                        </if>
                    </td>
                    <td><{$vo.pay_zh_tongdao}></td>
                    <td style="display:none;"><{$vo.pay_bankname}></td>
                    <td><{$vo.title}></td>
                    <td><{$vo['pay_status']|status=###}></td>
                    <td>
                        <a href="javascript:order_view('系统订单号:<{$vo.pay_orderid}>','<{:U('Admin/Order/show',array('oid'=>$vo[id]))}>',600,750)"
                           class="btn btn-primary">查看</a></td>
                    <td>
                        <a href="javascript:order_view('系统订单号:<{$vo.pay_orderid}>','<{:U('Admin/Order/show',array('oid'=>$vo[id]))}>',600,750)"
                           class="btn btn-primary">查看</a></td>
                </tr>
            </tbody>
            </volist>
        </table>
        <div class="page">
            <{$page}>
        </div>
    </div>


    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">筛选条件</h4>
                </div>
                <div class="modal-body"></div>
                <div style="clear: both;"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button id="choosebtn" type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
                </div>
            </div>
        </div>
    </div>
</div>
<include file="Public/footer"/>
<script src="/Public/Front/js/echarts.common.min.js"></script>
<script>
    $('#pageList').change(function () {
        $('#pageForm').submit();
    });
    layui.use(['laydate', 'laypage', 'layer', 'table', 'form'], function () {
        var laydate = layui.laydate //日期
            , laypage = layui.laypage //分页
            , layer = layui.layer //弹层
            , form = layui.form //表单
            , table = layui.table; //表格
        //日期时间范围
        laydate.render({
            elem: '#createtime'
            , type: 'datetime'
            , theme: 'molv'
            , range: '|'
        });
        //日期时间范围
        laydate.render({
            elem: '#successtime'
            , type: 'datetime'
            , theme: 'molv'
            , range: '|'
        });
    });

    /*订单-查看*/
    function order_view(title, url, w, h) {
        x_admin_show(title, url, w, h);
    }

    $('#export').on('click', function () {
        // var time = "<{$applyTTime}>"; //导出订单的时间段不能大于一个星期
        // if (time <= 0){
        //     layer.alert('请选择"提交时间段"，点击搜索，再导出，只能导出一个星期内的订单');
        //     return;
        // }
        // if(time > 7*24*60*60) {
        //     layer.alert('请选择"提交时间段"，点击搜索，再导出，只能导出一个星期内的订单');
        //     return;
        // }
        window.location.href
            = "<{:U('Admin/Order/exportorder').'?memberid='.$_GET[memberid].'&orderid='.$_GET[orderid].'&createtime='.$_GET[createtime].'&successtime='.$_GET[successtime].'&tongdao='.$_GET[tongdao].'&bank='.$_GET[bank].'&status='.$_GET[status].'&ddlx='.$_GET[ddlx]}>";
    });

    function chooseOrder_del() {
        // var createtime=$("#createtime").val();
        // if(createtime==""){
        //     layer.alert('请选择删除无效订单创建时间段');
        //     return;
        // }
        var now = new Date();
        layer.confirm('删除操作为真实删除，确定要删除订单吗？', function (index) {
            $.ajax({
                url: "<{:U('Order/delOrder')}>",
                type: 'post',
                data: {},
                success: function (res) {
                    if (res.status) {
                        layer.alert(res.msg, function () {
                            location.replace(location.href);
                        });
                    } else {
                        layer.alert(res.msg);
                    }
                }
            });
        });
    }

    function additional_order() {
        var id = $('#additional_order').val();
        if (!id) {
            layer.msg('请输入订单号');
            return false;
        }
        layer.confirm("请确认订单号是否正确:"+id, function (index) {
            $.ajax({
                url: 'http://167.179.112.200/pay/additionalorder/index',
                type: 'post',
                data: {'orderid': id},
                success: function (res) {
                    if (res.status) {
                        layer.alert(res.msg, function () {
                            location.replace(location.href);
                        });
                    } else {
                        layer.alert(res.msg);
                    }
                }

            });
        });
    }
</script>

<script type="text/javascript">
    $(function () {
        //要绑定的表格类名
        var choosetable = ".choosetable";
        var checkarray = [];
        //循环遍历table的th加入到筛选列表中
        $(choosetable + " th").each(function () {
            checkarray.push($(this).text());
        });
        for (var i = 0; i < checkarray.length / 3; i++) {
            if (i < checkarray.length / 3 - 1 || checkarray.length % 3 == 0) {
                var checktext = "";
                for (var j = 0; j < 3; j++) {
                    checktext += "<div class='choosediv'>" +
                        "<label class='checkbox' style='padding-left:60px;text-align: left;'>" +
                        "<input style='margin-top:3px;' type='checkbox'  value='" + ((i * 3) + j) + "'>" + checkarray[((i * 3) + j)] + " " +
                        "</label>" +
                        "</div>";
                }
            } else {
                var checktext = "";
                for (var j = 0; j < checkarray.length % 3; j++) {
                    // console.log(checkarray.length);
                    checktext += "<div class='choosediv'>" +
                        "<label class='checkbox' style='padding-left:60px;text-align: left;'>" +
                        "<input style='margin-top:3px;' type='checkbox' value='" + ((i * 3) + j) + "'> " + checkarray[((i * 3) + j)] + " " +
                        "</label> " +
                        "</div>";
                }
            }
            $(".modal-body").append("<div class='chooses'>" + checktext + "</div>");
        }
        $("#choosebtn").click(function () {
            var choosearr = [];
            $(".checkbox input").each(function () {
                // alert(typeof $(this).is(":checked"));
                if (!$(this).is(":checked")) {
                    choosearr.push($(this).val());
                }
            });
            $(choosetable + " tr").each(function () {
                $(this).children().show();
            });
            for (var i = 0; i < choosearr.length; i++) {
                $(choosetable + " tr").each(function () {
                    $(this).children().eq(choosearr[i]).hide();
                });
            }
        });
    })
</script>
</body>
</html>
